home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
e33el2.zip
/
emacs
/
19.33
/
lisp
/
inf-lisp.el
< prev
next >
Wrap
Lisp/Scheme
|
1996-05-23
|
27KB
|
643 lines
;;; inf-lisp.el --- an inferior-lisp mode
;; Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc.
;; Author: Olin Shivers <shivers@cs.cmu.edu>
;; Keywords: processes, lisp
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
;; This file defines a a lisp-in-a-buffer package (inferior-lisp
;; mode) built on top of comint mode. This version is more
;; featureful, robust, and uniform than the Emacs 18 version. The
;; key bindings are also more compatible with the bindings of Hemlock
;; and Zwei (the Lisp Machine emacs).
;; Since this mode is built on top of the general command-interpreter-in-
;; a-buffer mode (comint mode), it shares a common base functionality,
;; and a common set of bindings, with all modes derived from comint mode.
;; This makes these modes easier to use.
;; For documentation on the functionality provided by comint mode, and
;; the hooks available for customising it, see the file comint.el.
;; For further information on inferior-lisp mode, see the comments below.
;; Needs fixin:
;; The load-file/compile-file default mechanism could be smarter -- it
;; doesn't know about the relationship between filename extensions and
;; whether the file is source or executable. If you compile foo.lisp
;; with compile-file, then the next load-file should use foo.bin for
;; the default, not foo.lisp. This is tricky to do right, particularly
;; because the extension for executable files varies so much (.o, .bin,
;; .lbin, .mo, .vo, .ao, ...).
;;
;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
;; had a verbose minor mode wherein sending or compiling defuns, etc.
;; would be reflected in the transcript with suitable comments, e.g.
;; ";;; redefining fact". Several ways to do this. Which is right?
;;
;; When sending text from a source file to a subprocess, the process-mark can
;; move off the window, so you can lose sight of the process interactions.
;; Maybe I should ensure the process mark is in the window when I send
;; text to the process? Switch selectable?
;;; Code:
(require 'comint)
(require 'lisp-mode)
;;;###autoload
(defvar inferior-lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
"*What not to save on inferior Lisp's input history.
Input matching this regexp is not saved on the input history in Inferior Lisp
mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword
\(as in :a, :c, etc.)")
(defvar inferior-lisp-mode-map nil)
(cond ((not inferior-lisp-mode-map)
(setq inferior-lisp-mode-map
(copy-keymap comint-mode-map))
(setq inferior-lisp-mode-map
(nconc inferior-lisp-mode-map shared-lisp-mode-map))
(define-key inferior-lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)
(define-key inferior-lisp-mode-map "\C-c\C-l" 'lisp-load-file)
(define-key inferior-lisp-mode-map "\C-c\C-k" 'lisp-compile-file)
(define-key inferior-lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
(define-key inferior-lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
(define-key inferior-lisp-mode-map "\C-c\C-f"
'lisp-show-function-documentation)
(define-key inferior-lisp-mode-map "\C-c\C-v"
'lisp-show-variable-documentation)))
;;; These commands augment Lisp mode, so you can process Lisp code in
;;; the source files.
(define-key lisp-mode-map "\M-\C-x" 'lisp-eval-defun) ; Gnu convention
(define-key lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) ; Gnu convention
(define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-defun)
(define-key lisp-mode-map "\C-c\C-r" 'lisp-eval-region)
(define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-defun)
(define-key lisp-mode-map "\C-c\C-z" 'switch-to-lisp)
(define-key lisp-mode-map "\C-c\C-l" 'lisp-load-file)
(define-key lisp-mode-map "\C-c\C-k" 'lisp-compile-file) ; "kompile" file
(define-key lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
(define-key lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
(define-key lisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation)
(define-key lisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation)
;;; This function exists for backwards compatibility.
;;; Previous versions of this package bound commands to C-c <letter>
;;; bindings, which is not allowed by the gnumacs standard.
;;; "This function binds many inferior-lisp commands to C-c <letter> bindings,
;;;where they are more accessible. C-c <letter> bindings are reserved for the
;;;user, so these bindings are non-standard. If you want them, you should
;;;have this function called by the inferior-lisp-load-hook:
;;; (setq inferior-lisp-load-hook '(inferior-lisp-install-letter-bindings))
;;;You can modify this function to install just the bindings you want."
(defun inferior-lisp-install-letter-bindings ()
(define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
(define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go)
(define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go)
(define-key lisp-mode-map "\C-cz" 'switch-to-lisp)
(define-key lisp-mode-map "\C-cl" 'lisp-load-file)
(define-key lisp-mode-map "\C-ck" 'lisp-compile-file)
(define-key lisp-mode-map "\C-ca" 'lisp-show-arglist)
(define-key lisp-mode-map "\C-cd" 'lisp-describe-sym)
(define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
(define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation)
(define-key inferior-lisp-mode-map "\C-cl" 'lisp-load-file)
(define-key inferior-lisp-mode-map "\C-ck" 'lisp-compile-file)
(define-key inferior-lisp-mode-map "\C-ca" 'lisp-show-arglist)
(define-key inferior-lisp-mode-map "\C-cd" 'lisp-describe-sym)
(define-key inferior-lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
(define-key inferior-lisp-mode-map "\C-cv"
'lisp-show-variable-documentation))
;;;###autoload
(defvar inferior-lisp-program "lisp"
"*Program name for invoking an inferior Lisp with for Inferior Lisp mode.")
;;;###autoload
(defvar inferior-lisp-load-command "(load \"%s\")\n"
"*Format-string for building a Lisp expression to load a file.
This format string should use `%s' to substitute a file name
and should result in a Lisp expression that will command the inferior Lisp
to load that file. The default works acceptably on most Lisps.
The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\n\"
produces cosmetically superior output for this application,
but it works only in Common Lisp.")
;;;###autoload
(defvar inferior-lisp-prompt "^[^> \n]*>+:? *"
"Regexp to recognise prompts in the Inferior Lisp mode.
Defaults to \"^[^> \\n]*>+:? *\", which works pretty good for Lucid, kcl,
and franz. This variable is used to initialize `comint-prompt-regexp' in the
Inferior Lisp buffer.
More precise choices:
Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\"
franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
kcl: \"^>+ *\"
This is a fine thing to set in your .emacs file.")
(defvar inferior-lisp-buffer nil "*The current inferior-lisp process buffer.
MULTIPLE PROCESS SUPPORT
===========================================================================
To run multiple Lisp processes, you start the first up
with \\[inferior-lisp]. It will be in a buffer named `*inferior-lisp*'.
Rename this buffer with \\[rename-buffer]. You